//============================================================
// WbNdis.h
//

#define	OS_PACKET_SIZE( _A )	\
	(!Adapter->WbNdis.shutdown && Adapter->WbNdis.first_packet) ? RESERVED(Adapter->WbNdis.first_packet)->NdisPacketSize : 0
#define OS_LINK_STATUS			(Adapter->WbNdis.connect_status==NDIS_STATUS_MEDIA_CONNECT)
#define OS_SET_SHUTDOWN( _A )					WBNDIS_SET_SHUTDOWN( _A )
#define OS_SET_RESUME( _A )						WBNDIS_SET_RESUME( _A )
#define OS_CONNECT_STATUS_INDICATE( _A, _F )	WBNDIS_ConnectStatus( _A, _F )
#define OS_CURRENT_RX_BYTE( _A )		(_A->WbNdis.RxByteCount)
#define OS_CURRENT_TX_BYTE( _A )		(_A->WbNdis.TxByteCount)
#define OS_RECEIVE_PACKET_INDICATE( _A, _D )	WBNDIS_ReceivePacket( _A, _D )
#define OS_STOP( _A )			WBNDIS_stop( _A )
#define OS_GET_PACKET( _A, _D )				WBNDIS_GetNextPacket( _A, _D )
#define OS_GET_PACKET_COMPLETE( _A, _D )	WBNDIS_GetNextPacketCompleted( _A, _D )
#define OS_SEND_RESULT( _A, _ID, _R )

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#ifdef NDIS50_MINIPORT	// 20060726
#define WB_NDIS_STATUS_NOT_SUPPORTED		NDIS_STATUS_FAILURE
#else
#define WB_NDIS_STATUS_NOT_SUPPORTED		NDIS_STATUS_NOT_SUPPORTED
#endif

// NDIS Version definition
#define WB32_NDIS_MAJOR_VERSION		5
#define WB32_NDIS_MINOR_VERSION		0

//Customize OID by vender
#define OID_802_11_CUST_LINK_QUALITY        0xFF000000
#define OID_802_11_CUST_HW_VERSION          0xFF000001
#define OID_802_11_CUST_DRV_VERSION			0xFF000002
#define OID_802_11_CUST_PREAMBLE_TYPE       0xFF000003//added by ws 09/28/04
// add for radio on/off control
#define OID_802_11_CUST_RADIO               0xFF000004
// add for region control
#define OID_802_11_CUST_REGION              0xFF000005
#define OID_802_11_CUST_DRV_NAME            0xFF000006

// 20041021 1.1.81.1000 ybjiang
// add for radio notification 
#define OID_802_11_CUST_RADIO_NOTIFICATION  0xFF000007

// 20041026 1.1.83.1000 ybjiang
#define OID_802_11_CUST_IBSS_FREQUENCY      0xFF000008

// 20041102 1.1.91.1000 ybjiang
#define OID_802_11_CUST_REGION_CAPABILITIES 0xFF000009

/** 1.1.97 Turbo add for Qcom case */
#define OID_802_11_CUST_ENCRYPTION_STATUS   0xFF00000A

//sky added 20050803
#define OID_802_11_CUST_TX_THROUGHPUT		0xFF00000B
#define OID_802_11_CUST_RX_THROUGHPUT		0xFF00000C
//sky added 20050817
#define OID_802_11_CUST_RF_TYPE				0xFF00000D

// 20061108 WPS
#define OID_802_11_CUST_IE_APPEND			0xFF00000E
#define OID_802_11_CUST_LED_CONTROL			0xFF00000F

#define WBNDIS_SET_SHUTDOWN( _A )	_A->WbNdis.shutdown=1
#define WBNDIS_SET_RESUME( _A )		_A->WbNdis.shutdown=0

#define MAX_ADAPTER_COUNT			8

////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _WBNDIS
{
	NDIS_SPIN_LOCK	SpinLock; // For Tx spinlock
	ULONG	shutdown;// 931130.4.s

	// For storing the 802.3 NDIS packet
	PNDIS_PACKET	first_packet;
	PNDIS_PACKET	last_packet;
	PNDIS_PACKET	packet_return;

	OS_ATOMIC	ThreadCount;

	//==============================================
	// For NDIS
	//==============================================
	NDIS_HANDLE		PacketPoolHandle;
	NDIS_HANDLE		BufferPoolHandle;

	UCHAR			NdisPacketPoolOk;// 931130.4.t
	UCHAR			PacketAllocateCount;// 931130.4.t
	UCHAR			NdisBufferPoolOk;// 931130.4.t
	UCHAR			RESERVED_c;

	PNDIS_PACKET	ReceivePacket[ ETHERNET_RX_DESCRIPTORS ];
	PNDIS_BUFFER	ReceiveBuffer[ ETHERNET_RX_DESCRIPTORS ];

    NDIS_HANDLE             MiniportAdapterHandle;
    //NDIS_HANDLE             ConfigurationHandle;
    NDIS_STATUS             connect_status;

	// For collect each buffer
	UCHAR		NdisBufferTmp[1520];

	// For counting throughput for 802.3 frame
	ULONG		TxByteCount; // 802.3 frame send byte count
	ULONG		RxByteCount; // 802.3 frame receive byte count
	ULONG		TxByteCount_last; // 802.3 frame send byte count
	ULONG		TxRateShowResult;
	OS_TIMER	TxRateTimer;

	NDIS_STRING			DeviceName; // 20060721 move here
    NDIS_STRING			DeviceLinkUnicodeString;

	ULONG	DisconnectIndicate;

} WBNDIS, *PWBNDIS;


//
// Type of an interrupt.
//--------------------------------------------

/*typedef enum
{
	BUSERR              = 0x01,
	RECEIVE             = 0x02,
	TRANSMIT            = 0x04,
	RXBUFFERUNAVAILABLE = 0x08,
    TSFSYNCOK           = 0x10,             
    UNKNOWN             = 0x11,             
} INTERRUPT_TYPE;
*/

// Using this OOB for store additional information : 4+4+2+1+1=12
typedef struct _MINIPORT_RESERVED {  
               PNDIS_PACKET Next;               // used to link in the queues (4 bytes)
			   union
			   {
					PUCHAR			MLME_DataBuffer;    //  
					PNDIS_BUFFER	pNdisPacketBuffer;
			   };

			   union
			   {
					USHORT		MLME_Size;          //
					USHORT		NdisPacketSize;
			   };
			   UCHAR		Flag;               //
			   UCHAR		FrameType;          //
} MINIPORT_RESERVED, *PMINIPORT_RESERVED;

//
// Retrieve the MINIPORT_RESERVED structure from a packet.
// MiniportReservedEx = 3*4=12   
#define RESERVED(Packet)            \
        ((PMINIPORT_RESERVED)((Packet)->MiniportReservedEx))

extern ANSI_STRING g_String;
extern char g_NicName[100];
